#include "GameControl.h"

GameControl::GameControl(Graphics& gfx, HWND hWnd, int width, int height)
	:
	_gfx(gfx),
	_hWnd(hWnd),
	_width(width),
	_height(height)
{
	_Menu = std::make_unique<Menu>(gfx, width, height);
	_line = std::make_unique<Primitive>(gfx);
}

GameControl::~GameControl()
{

}

void GameControl::GameScreen()
{
	_gfx.StartRender(0, 0, 0);

	_Spaceship->Keydown();
	_Spaceship->Run(1.0f);
	_Spaceship->Draw(_gfx);
	_Spaceship->Coordinate(_gfx);

	_TimeFont->FPS(_gfx);

	_gfx.EndRender();
}

void GameControl::GameMenu()
{
	_gfx.StartRender(0, 0, 0);

	_Menu->Draw(_gfx, _hWnd);

	_gfx.EndRender();
}

void GameControl::LineScene()
{
	_gfx.StartRender(0, 0, 0);

	_line->Draw(_gfx);

	_gfx.EndRender();
}

void GameControl::TriangleScene()
{
	_gfx.StartRender(0, 0, 0);

	_triangle->Draw(_gfx);

	_gfx.EndRender();
}

void GameControl::RotatingTriangleScreen()
{
	_gfx.StartRender(0, 0, 0);

	_RotatingTriangle->Draw(_gfx);

	_TimeFont->Draw(_gfx);

	_gfx.EndRender();
}

void GameControl::GameRun()
{
	if (GetAsyncKeyState(VK_RBUTTON)) {
		g_GameState = GameState::GameMenu;
	}
	switch (g_GameState)
	{
	case GameState::GameMenu:
		GameMenu();
		break;
	case GameState::RunGame:
		break;
	case GameState::LineScreen:
		LineScene();
		break;
	case GameState::TriangleScreen:
		TriangleScene();
		break;
	case GameState::RotatingTriangleScreen:
		RotatingTriangleScreen();
		break;
	case GameState::GameRun:
		GameRun();
		break;
	default:
		break;
	}
}
